<template>
  <header class="kxz-callLog__header">
    <el-form :inline="true" >
      <el-form-item label="" :class="$style.tinyModify">
        <el-input v-model="telNum" placeholder="请输入手机号码" @keyup.enter.native="handleCallout"></el-input>
      </el-form-item>
       <el-form-item label="" :class="$style.tinyModify" v-show="0">
        <el-input v-model="telNum" placeholder="请输入手机号码" @keyup.enter.native="handleCallout"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleCallout">呼出</el-button>
      </el-form-item>
    </el-form>
  </header>
</template>

<script>
import {callout} from '../../../config/mixin'

export default {
  name: 'log-header',
  mixins: [callout],
  data() {
    return {
      telNum: ''
    }
  },
  props: {
    flag1: {
      type: Number,
      default: 0
    }
  },
  methods: {
    async handleCallout(){
      const phone = this.telNum
      // if (new RegExp('^0?((13[0-9])|(15[^,\\D])|(17[0-9])|(147)|(18[0-9]))\\d{8}$').test(phone) === false) {
      //   this.$toast({
      //     message:'请输入正确的手机号码'
      //   })
      //   return
      // }
      //
      // this.$toast({
      //   message:phone
      // })
      // return
      
      if(phone === ''){
        this.$toast({
          message:'请输入号码'
        })
        return
      }
      const {usertel} = this.$store.getters.getUserInfo
      try{
        const {data} = await this.$get(this,{
          api:'ajaxapi/isFouWz.do',
          data: {
            mobile: phone,
            yhm: usertel
          }
        })
        if(data.state === 0){
          this.callout(data.content,this.flag1)
        }
      }catch(e){
        this.$warn('系统接口ajaxapi/isFouWz.do报错')
      }
    }
  }
}
</script>

<style lang="scss" module>
.tinyModify{
  margin-right:18px !important;
  margin-bottom:16px !important;
}
</style>

<style lang="scss">
.callLog__header{
  padding-left:12px;
  .el-input__inner{
    height:40px;
    padding-left:19px;
    padding-right:5px;
    color:#7b8897;
    border: 1px solid #eaecf1;
    background:#fafbfc;
  }
  .el-button{
    padding:12px 20px;
  }
}

</style>
